package qq.util;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class SeleniumUtil {

  public static  WebDriver driver = new FirefoxDriver();
  static int i ;
   public static void waitForElements(final By[] by){
	for (i=0; i < by.length; i++) {
		WebDriverWait wait = new WebDriverWait(driver,10);
		wait.until(new ExpectedCondition<WebElement>(){

			@Override
			public WebElement apply(WebDriver d) {
				return d.findElement(by[i]);
			}
		});
	}

	
	
}
	
	public static  WebElement findElement(By by){
		return driver.findElement(by);
	}
	
	public static void elementSendKey(WebElement element,String keysToSend){
		element.sendKeys(keysToSend);
		}
	
	public static void click(WebElement elment){
		elment.click();
	}
	
	public static void quit(){
		driver.close();
	}
	 public static void getURL(String url){
		 driver.get(url);
	 }
	
}
